if exists(select name from sysobjects where name = 'sp_SanPhamUpperByTenSanPham')
	drop proc sp_SanPhamUpperByTenSanPham
go
/*
	Created by: Phuoc NH
	Created on: 18/01/2013 (dd/mm/yyyy)
	Description: lay loai san pham theo id
	--
	File:$sql-scripts/Proc.sp_SanPhamUpperByTenSanPham.sql
*/
create proc sp_SanPhamUpperByTenSanPham
as
begin

	declare @San_pham_id int
	declare @Ten_san_pham Nvarchar(max)
	
	declare contro cursor for select san_pham_id, Ten_san_pham from tbl_san_pham where status=1
	open contro
	fetch next from contro into @san_pham_id, @ten_san_pham
	while(@@FETCH_STATUS=0)
		begin
			set @ten_san_pham= dbo.fn_UpperBySpace(@Ten_san_pham)
			update tbl_San_pham set Ten_san_pham=@Ten_san_pham where San_pham_id=@San_pham_id
			fetch next from contro into @San_pham_id, @ten_san_pham
		end
	close contro
	deallocate contro
	
end
go
exec sp_SanPhamUpperByTenSanPham 